//
//  GJFPlotDetailIntroductionTableViewCell.m
//  Wedding
//
//  Created by 郭静芬 on 2016/12/23.
//  Copyright © 2016年 郭静芬. All rights reserved.
//

#import "GJFPlotDetailIntroductionTableViewCell.h"

@interface GJFPlotDetailIntroductionTableViewCell ()
{
    NSInteger fontSize;
    NSInteger item_H;
}
@property (nonatomic, strong) UILabel *time;
@property (nonatomic, strong) UILabel *location;
@property (nonatomic, strong) UILabel *theme;
@property (nonatomic, strong) UILabel *photo;
@property (nonatomic, strong) UILabel *video;
@property (nonatomic, strong) UILabel *makeup;
@property (nonatomic, strong) UILabel *emcee;
@property (nonatomic, strong) UILabel *floriculture;
@property (nonatomic, strong) UILabel *price;
@property (nonatomic, strong) UILabel *describe;
//@property (nonatomic, assign) 
//@property (nonatomic, assign)
@end

@implementation GJFPlotDetailIntroductionTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        fontSize = 14;
        item_H = 25;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.contentView.mas_top).mas_offset(20);
            make.height.mas_equalTo(20);
        }];
        [self.location mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.time.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.theme mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.location.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.photo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.theme.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.video mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.photo.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.makeup mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.video.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.emcee mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.makeup.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.floriculture mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.emcee.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.floriculture.mas_top).mas_offset(10);
            make.height.mas_equalTo(20);
        }];
        [self.describe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-20);
            make.top.mas_equalTo(self.price.mas_top).mas_offset(20);
            make.height.mas_equalTo(20);
        }];
    }
    return self;
}
#pragma mark - setter方法 - 赋值并根据是否有值更改位置
- (void)setPlotModel:(GJFPlotModel *)plotModel {
    _plotModel = plotModel;
    if (!plotModel) {
        return;
    }
    CGFloat h = 20;
    if (plotModel.wedding_time) {
        self.time.text = [NSString stringWithFormat:@"婚礼日期：%@", plotModel.wedding_time];
        [self.time mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    } else {
        [self.time mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_location) {
        self.location.text = [NSString stringWithFormat:@"婚礼场地：%@", plotModel.wedding_location];
        [self.location mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.location mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_theme) {
        self.theme.text = [NSString stringWithFormat:@"婚礼主题：%@", plotModel.wedding_theme];
        [self.theme mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.theme mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    
    if (plotModel.wedding_photo) {
        self.photo.text = [NSString stringWithFormat:@"婚礼摄影：%@", plotModel.wedding_photo];
        [self.photo mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.photo mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_video) {
        self.video.text = [NSString stringWithFormat:@"婚礼摄像：%@", plotModel.wedding_video];
        [self.video mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.video mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_makeup) {
        self.makeup.text = [NSString stringWithFormat:@"婚礼造型：%@", plotModel.wedding_makeup];
        [self.makeup mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.makeup mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_emcee) {
        self.emcee.text = [NSString stringWithFormat:@"婚礼司仪：%@", plotModel.wedding_emcee];
        [self.emcee mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.emcee mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_floriculture) {
        self.floriculture.text = [NSString stringWithFormat:@"婚礼花艺：%@", plotModel.wedding_floriculture];
        [self.floriculture mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.floriculture mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.wedding_price) {
        self.price.text = [NSString stringWithFormat:@"婚礼参考价：%@", plotModel.wedding_price];
        [self.price mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.height.mas_equalTo(20 * YY);
        }];
        h += item_H;
    }
    else {
        [self.price mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    if (plotModel.describe) {
        self.describe.text = plotModel.describe;
        [self.describe mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10 * XX);
            make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10 * XX);
            make.top.mas_equalTo(self.mas_top).mas_offset(h);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).mas_offset(-10 * YY);
        }];
    }
    else {
        [self.describe mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
}

#pragma mark - 懒加载
- (UILabel *)time {
    if (!_time) {
        _time = [[UILabel alloc] init];
        _time.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_time];
    }
    return _time;
}
- (UILabel *)location {
    if (!_location) {
        _location = [[UILabel alloc] init];
        _location.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_location];
    }
    return _location;
}
- (UILabel *)theme {
    if (!_theme) {
        _theme = [[UILabel alloc] init];
        _theme.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_theme];
    }
    return _theme;
}
- (UILabel *)photo {
    if (!_photo) {
        _photo = [[UILabel alloc] init];
        _photo.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_photo];
    }
    return _photo;
}
- (UILabel *)video {
    if (!_video) {
        _video = [[UILabel alloc] init];
        _video.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_video];
    }
    return _video;
}
- (UILabel *)makeup {
    if (!_makeup) {
        _makeup = [[UILabel alloc] init];
        _makeup.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_makeup];
    }
    return _makeup;
}
- (UILabel *)emcee {
    if (!_emcee) {
        _emcee = [[UILabel alloc] init];
        _emcee.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_emcee];
    }
    return _emcee;
}
- (UILabel *)floriculture {
    if (!_floriculture) {
        _floriculture = [[UILabel alloc] init];
        _floriculture.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_floriculture];
    }
    return _floriculture;
}
- (UILabel *)price {
    if (!_price) {
        _price = [[UILabel alloc] init];
        _price.font = [UIFont systemFontOfSize:14 * XX];
        [self .contentView addSubview:_price];
    }
    return _price;
}
- (UILabel *)describe {
    if (!_describe) {
        _describe = [[UILabel alloc] init];
        _describe.numberOfLines = 0;
        _describe.font = [UIFont systemFontOfSize:14 * XX];
        [self.contentView addSubview:_describe];
    }
    return _describe;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
